package com.spzx.report.utils.embedding;

import com.spzx.report.constant.EmbeddingModelConst;
import dev.langchain4j.data.embedding.Embedding;
import dev.langchain4j.model.openai.OpenAiEmbeddingModel;
import dev.langchain4j.model.output.Response;

/**
 * Package: com.spzx.report.utils
 *
 * @author xiongkunYang
 * @description:
 * @since 2025/6/10 16:39
 */

public class EmbeddingUtil {

    public static Embedding getEmbedding(String text) {
        OpenAiEmbeddingModel model = OpenAiEmbeddingModel.builder()
                .baseUrl(EmbeddingModelConst.BASE_URL)
                .apiKey(EmbeddingModelConst.API_KEY)
                .modelName(EmbeddingModelConst.EMBEDDING_MODEL_NAME)
                .dimensions(1536)
                .build();

        Response<Embedding> embed = model.embed(text);
        return embed.content();
    }
}